---
image: /generated/articles-docs-whisper-web-to-captions.png
title: toCaptions()
crumb: '@remotion/whisper-web'
---

# toCaptions()

Converts the output from [`transcribe()`](/docs/whisper-web/transcribe) into an array of [`Caption`](/docs/captions/caption) objects, so you can use the functions from [`@remotion/captions`](/docs/captions).

```tsx twoslash
import {toCaptions, transcribe, resampleTo16Khz} from '@remotion/whisper-web';

const file = new File([], 'audio.wav');

const channelWaveform = await resampleTo16Khz({
  file,
});

const whisperWebOutput = await transcribe({
  channelWaveform,
  model: 'tiny.en',
});

const {captions} = toCaptions({
  whisperWebOutput,
});

console.log(captions); /*
 [
    {
      text: "William",
      startMs: 40,
      endMs: 420,
      timestampMs: 240,
      confidence: 0.813602,
    }, {
      text: " just",
      startMs: 420,
      endMs: 650,
      timestampMs: 480,
      confidence: 0.990905,
    }, {
      text: " hit",
      startMs: 650,
      endMs: 810,
      timestampMs: 700,
      confidence: 0.981798,
    }
  ]
*/
```

## See also

- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/whisper-web/src/to-captions.ts)
- [`@remotion/whisper-web`](/docs/whisper-web)
- [`@remotion/captions`](/docs/captions)
